import pandas as pd


def pre_do():
    # 文件路径
    biao_in = '../data/创业板指原文.xlsx'
    biao_out = '../data/创业板指研究.xlsx'
    df = pd.read_excel(biao_in, sheet_name='Sheet1')
    print("预览:", df.head())

    # 把挤在一起的年月日拆开
    df['date'] = pd.to_datetime(df['交易日期'])
    df['year'] = df['date'].dt.year
    df['month'] = df['date'].dt.month
    df['day'] = df['date'].dt.day
    df['weekday'] = df['date'].dt.weekday + 1

    # 需要保留的数据
    del df['date'], df['交易日期']
    df = df[['year', 'month', 'day', 'weekday', '收盘价', '涨幅(%)']]
    df.to_excel(biao_out, index=False)
    return


if __name__ == "__main__":
    pre_do()
